Skip to content

[Python] Propagate WriteToFiles finalization failures - #39993

Merged
jrmccluskey merged 2 commits into
apache:masterfrom
bvolpato:bvolpato/python-fileio-finalization-errors
Sep 10, 2026
Merged

[Python] Propagate WriteToFiles finalization failures#39993
jrmccluskey merged 2 commits into
apache:masterfrom
bvolpato:bvolpato/python-fileio-finalization-errors

Conversation

@bvolpato

@bvolpato bvolpato commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

WriteToFiles currently catches every BeamIOError from final renames and emits successful FileResults even when the destination files are absent. A genuine I/O failure can therefore leave data in temporary files while the pipeline reports success.

Propagate rename failures so the bundle can retry. Before renaming, skip a file only when its temporary source is absent and its final destination exists, preserving retries after complete or partial finalization. An existing destination does not suppress errors while the source remains.

Five regression tests cover failed renames without successful output, already-completed retries, partial moves followed by retry, stale destinations, and missing files. Against the unfixed implementation, four fail and the completed-retry compatibility test passes.

Testing

From sdks/python, with the SDK and test dependencies installed:

python -m pytest apache_beam/io/fileio_test.py -q

Python 3.12: 49 passed, 2 skipped. YAPF 0.43.0, Ruff 0.15.22, and git diff --check pass for the changed files.

Downsides

Finalization adds one existence lookup per temporary file, plus a destination lookup when that source is absent. Remote filesystems incur these metadata requests before the existing batched rename. Genuine finalization errors now fail the bundle instead of being suppressed.


  • Describe the bug and include reproducible regression tests; no separate Python issue is linked.
  • Update CHANGES.md with the behavior change.
  • Apache Individual Contributor License Agreement, if required for this contribution.

See the Contributor Guide and CI documentation.

@bvolpato
bvolpato marked this pull request as ready for review September 10, 2026 04:15
@github-actions

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @jrmccluskey for label python.

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

@jrmccluskey jrmccluskey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@jrmccluskey
jrmccluskey merged commit f5ba5fa into apache:master Sep 10, 2026
101 checks passed
@Abacn

Abacn commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Downsides: Finalization adds one existence lookup per temporary file

This is a significant performance concern we should revisit. It's a common use case FileIO processing millions of files and a known bottleneck to listing metadata from gcs files (#20137). I remember each GET call takes ~100 ms. This adds hours of wall time when write to large number of files

@Abacn

Abacn commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

If we want to be able to propagate error early, consider using Beam's dead letter queue framework that is allow user to choose an error_handler that either throws or relay the error happens

@Abacn

Abacn commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Thanks for contribution. We're trying to find ways handle increasing flux of contributions while keep the codebase robustness. As first step #40002 revised agent skills, PR labelling and review guidelines to advice both contributor and reviewer pay additional attention for core code paths.

In the future the "Assigning reviewers" comment will contain the component specific guidelines for reviewers, e.g.

This pull request likely touches a core component ("core" label). Please review with scrutiny.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants